package com.sudo.rpc.server.task;

import com.sudo.rpc.api.utils.RpcRes;
import com.sudo.rpc.server.annotation.Note;
import com.sudo.rpc.server.service.ServerInfoService;
import com.sudo.rpc.server.task.registry.BaseTaskRegistry;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.Map;

@Slf4j
public class ServerInfoModule extends BaseTaskRegistry {

    public ServerInfoModule(){
        setModuleClassMap(getClass());
    }

    @Resource
    private ServerInfoService serverInfoService;


    /**
     * 获取服务器节点内存实时信息
     */
    @Note(desc = "节点内存|Cpu信息")
    public RpcRes getServerCpuMemToRedis() {
        Map<String, Object> objectMap = serverInfoService.getServerDynamicMemCpu();
        return RpcRes.okCall(objectMap);
    }

    /**
     * 根据服务器节点获取系统信息
     */
    @Note(desc = "节点系统信息")
    public RpcRes getServerSysInfo() {
        Map<String, Object> objectMap = serverInfoService.getServerSysInfo();
        return RpcRes.okCall(objectMap);
    }

}
